<?php

use yii\bootstrap\BootstrapAsset;
use yii\db\Query;
use common\models\shop\ShopHouseOrder;
BootstrapAsset::register($this);

/***********应收***************/
$yingshusum = 0;
$house = (new Query())->select('ordersn,price,status')->from(ShopHouseOrder::tableName())->where(['houseid'=>$model->id])->all();
$yishusum = 0;
$yhouse = [];
if(!empty($house )){
    foreach ($house  as $key =>$row){
        if($row['status'] >= ShopHouseOrder::STATUS_PAY){       //已收
            $yhouse[] = $row;
            $yishusum += $row['price'];
        }
        $yingshusum += $row['price'];
    }
}

?>
<div class="row">
    <div class="col-md-6">
        <h4>应收</h4>
        <table class="table table-hover">
            <tr>
                <th>单号</th>
                <th>金额</th>
            </tr>
            <?php foreach ($house as $key => $row){ ?>
                <tr>
                    <td><?=$row['ordersn']?></td>
                    <td><?=$row['price']?></td>
                </tr>
            <?php } ?>
            <tr>
                <td>合计</td>
                <td><?=$yingshusum?></td>
            </tr>
        </table>
    </div>
    <div class="col-md-6">
        <h4>已收</h4>
        <table class="table table-hover">
            <tr>
                <th>单号</th>
                <th>金额</th>
            </tr>
            <?php foreach ($yhouse as $key => $row){ ?>
                <tr>
                    <td><?=$row['ordersn']?></td>
                    <td><?=$row['price']?></td>
                </tr>
            <?php } ?>
            <tr>
                <td>合计</td>
                <td><?=$yishusum?></td>
            </tr>
        </table>
    </div>
</div>


